<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>非父组件之间的通信-父链</title>
    <script src="https://cdn.staticfile.org/vue/2.6.11/vue.js"></script>
</head>
<body>
<div id="case13-demo6">
    <child-component></child-component>
    <div>{{msg}}</div>
</div>
<script type="text/javascript">
    var case13Demo6=new Vue({
        el:"#case13-demo6",
        data:{
            msg:"数据还没有被修改"
        },
        components:{
            'child-component':{
                template:'<button v-on:click="setFatherData">通过点击我修改父亲的数据</button>',
                methods:{
                    setFatherData:function () {
                        this.$parent.msg='数据已经被修改了'
                    }
                }
            }
        }
    })
</script>
</body>
</html>